package cn.ffcs.uec.outStaff.action;


import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.zkoss.web.servlet.Servlets;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zkplus.databind.BindingListModelList;
import org.zkoss.zul.Filedownload;
import org.zkoss.zul.ListModelList;
import org.zkoss.zul.Messagebox;

import cn.ffcs.raptornuke.plugin.common.zk.ctrl.BasePortletComposer;
import cn.ffcs.raptornuke.portal.kernel.xml.DocumentException;
import cn.ffcs.raptornuke.portal.theme.ThemeDisplay;
import cn.ffcs.uec.common.util.PermissionUtil;
import cn.ffcs.uec.common.vo.UecBdDefdoc;
import cn.ffcs.uec.outStaff.action.bean.UecOutStaffInfomationDownMainBean;
import cn.ffcs.uec.outStaff.manager.UecOutStaffInfomationManager;
import cn.ffcs.uec.outStaff.vo.UecOutStaffInfomationNew;
import cn.ffcs.uec.outStaff.vo.UecOutStaffInfomationVo;
import cn.ffcs.uec.staff.manager.UecAssManager;
import cn.ffcs.uec.staff.manager.UecDocEduManager;
import cn.ffcs.uec.staff.manager.UecEncManager;
import cn.ffcs.uec.staff.manager.UecWorkManager;
import cn.ffcs.uec.staff.model.UecAss;
import cn.ffcs.uec.staff.model.UecDocEdu;
import cn.ffcs.uec.staff.model.UecEnc;
import cn.ffcs.uec.staff.model.UecWork;
import cn.ffcs.uom.common.model.DefaultDaoFactory;
import cn.ffcs.uom.common.util.ApplicationContextUtil;
import cn.ffcs.uom.common.util.DateUtil;
import cn.ffcs.uom.common.util.ExportExcelNew;
import cn.ffcs.uom.common.util.IPortletInfoProvider;
import cn.ffcs.uom.common.util.ListboxUtils;
import cn.ffcs.uom.common.util.StrUtil;
import cn.ffcs.uom.common.util.UomZkUtil;
import cn.ffcs.uom.common.vo.NodeVo;
import cn.ffcs.uom.common.vo.PageInfo;
/**
 * 报表汇总下载
 * @author BMP
 * @time 2018-12-27
 */
@Controller
@Scope("prototype")
public class UecOutStaffInfomationDownMainComposer extends BasePortletComposer implements
		IPortletInfoProvider {
	
	private static final long serialVersionUID = -139335897781983790L;
	private UecOutStaffInfomationVo uecOutStaffInfomationVo = new UecOutStaffInfomationVo();
	
	private UecOutStaffInfomationNew uecOutStaffInfoNew = new UecOutStaffInfomationNew();
	private UecOutStaffInfomationManager uecOutStaffInfomationManager = (UecOutStaffInfomationManager) ApplicationContextUtil
			.getBean("uecOutStaffInfomationManager");
	private UecAssManager uecAssManager = (UecAssManager) ApplicationContextUtil
			.getBean("uecAssManager");
	private UecWorkManager uecWorkManager = (UecWorkManager) ApplicationContextUtil
			.getBean("uecWorkManager");
	private UecEncManager uecEncManager = (UecEncManager) ApplicationContextUtil
			.getBean("uecEncManager");
	private UecDocEduManager uecEduManager = (UecDocEduManager) ApplicationContextUtil
			.getBean("uecDocEduManager");

	private UecOutStaffInfomationDownMainBean bean = new UecOutStaffInfomationDownMainBean();
	//导出数据20181203初始版
	private static List<UecOutStaffInfomationVo> totalInfoList;
	//导出数据20191218整改版
	private static List<Map<String,Object>> totalInfoListNew;
	@Override
	public String getPortletId() {
		return super.getPortletId();
	}

	@Override
	public ThemeDisplay getThemeDisplay() {
		return super.getThemeDisplay();
	}

	@Override
	public void doAfterCompose(Component comp) throws Exception {
		super.doAfterCompose(comp);
		UomZkUtil.autoFitHeight(comp);
		Components.wireVariables(comp, bean);
	}
	/**
	 * 初始化窗口
	 * @throws ParseException 
	 * @throws com.itextpdf.text.DocumentException 
	 * @throws IOException 
	 * @throws DocumentException 
	 */
	public void onCreate$uecOutStaffInfomationDownMainWin() throws ParseException {
		//this.bindCombobox();
		onQueryUecOutStaffInfoVo();
	}
	/**
	 * 绑定combobox
	 */
	/*private void bindCombobox() {
		//获取登录人当前组织
		String currentOrgName = PermissionUtil.getManagerOrg();
		List<NodeVo> joinCategoryList = new ArrayList<NodeVo>();
		if("区本部".equals(currentOrgName)){
			String[][] glbdef10 = { { "阿拉", "前端经营类" }, { "后端支撑类", "后端支撑类" },
					{ "管控职能类", "管控职能类" }, { "财务类", "财务类" },
					{ "客服呼叫座席类", "客服呼叫座席类" } };
			for (int i = 0; i < glbdef10.length; i++) {
				NodeVo nodeVo = new NodeVo();
				for (int j = 0; j < 1; j++) {
					nodeVo.setId(glbdef10[i][j]);
					nodeVo.setName(glbdef10[i][j + 1]);
				}
				joinCategoryList.add(nodeVo);
			}
			ListboxUtils.rendererForEdit(bean.getJoinCategory(), joinCategoryList);
		}else{
			String[][] glbdef10 = { { "前端经营类", "前端经营类" }, { "后端支撑类", "后端支撑类" },
					{ "管控职能类", "管控职能类" }, { "财务类", "财务类" }
					 };
			for (int i = 0; i < glbdef10.length; i++) {
				NodeVo nodeVo = new NodeVo();
				for (int j = 0; j < 1; j++) {
					nodeVo.setId(glbdef10[i][j]);
					nodeVo.setName(glbdef10[i][j + 1]);
				}
				joinCategoryList.add(nodeVo);
			}
			ListboxUtils.rendererForEdit(bean.getJoinCategory(), joinCategoryList);
		}
		List<NodeVo> origeduList = new ArrayList<NodeVo>();
		String[][] glbdef12 = { { "中专", "中专" }, { "高中", "高中" },
				{ "技工学校", "技工学校" }, { "初中", "初中"},
				{ "小学", "小学" } };
		for (int i = 0; i < glbdef12.length; i++) {
			NodeVo nodeVo = new NodeVo();
			for (int j = 0; j < 1; j++) {
				nodeVo.setId(glbdef12[i][j]);
				nodeVo.setName(glbdef12[i][j + 1]);
			}
			origeduList.add(nodeVo);
		}
		ListboxUtils.rendererForEdit(bean.getOrigedu(), origeduList);
	}*/
	/**
	 * 取消
	 */
	public void onCancel() {
		this.bean.getUecOutStaffInfomationDownMainWin().onClose();
	}
	/**
	 * 重置按钮
	 */
	public void onResetOutStaff() {
		clearVariable();
		this.bean.getTotalSize().setValue(null);
		this.bean.getName().setValue(null);
		this.bean.getCode().setValue(null);
		this.bean.getIdNumber().setValue(null);
		ListboxUtils.clearListbox(this.bean.getUecOutStaffInfomationDownbox());
		this.bean.getUecOutStaffInfomationDownPaging().setTotalSize(1);
		// 防止重置后直接查询报错
		uecOutStaffInfomationVo = new UecOutStaffInfomationVo();
	}
	/**
	 * 确定
	 * @throws ParseException 
	 * @throws IOException 
	 * @throws InterruptedException 
	 */
	public void onOk() throws ParseException, IOException, InterruptedException {
	       // List<UecOutStaffInfomationVo> dataList3=uecOutStaffInfomationManager.qryUecOutStaffListByUecOutStaffInfo(uecOutStaffInfomationVo);
		   // totalInfoList=totalInfo(dataList3);
		if (!StrUtil.isEmpty(this.bean.getCode().getValue())) {
			uecOutStaffInfoNew.setPsnCode(this.bean.getCode().getValue());
		}
		if (!StrUtil.isEmpty(this.bean.getName().getValue())) {
			uecOutStaffInfoNew.setPsnName(this.bean.getName().getValue());
		}
		if (!StrUtil.isEmpty(this.bean.getIdNumber().getValue())) {
			uecOutStaffInfoNew.setIdNum(this.bean.getIdNumber().getValue());
		}
		totalInfoListNew = uecOutStaffInfomationManager.qryDataList(uecOutStaffInfoNew);
		if(totalInfoListNew !=null && totalInfoListNew.size() != 0) {
			
		
	            // 设置字符集
	            String charset = "UTF-8";
	            String fileName = "外包汇总信息_" + DateUtil.getYYYYMMDD(new Date());
	            HttpServletRequest httpRequest = (HttpServletRequest) Executions.getCurrent().getNativeRequest();
	           // byte[] content = downData();
	            ByteArrayOutputStream os = new ByteArrayOutputStream();
	            ExportExcelNew.exportExcel("", totalInfoListNew, os);
	            byte[] content = os.toByteArray();
	            String encodedName = null;
	            encodedName = URLEncoder.encode(fileName + ".xlsx", charset);
	            // 将空格替换为+号
	            encodedName = encodedName.replace("%20", "+");
	            // 解决ie6 bug 或者是火狐浏览器
	            if (encodedName.length() > 150 || Servlets.isGecko(httpRequest) || Servlets.isGecko3(httpRequest)) {
	                encodedName = new String(encodedName.getBytes(charset), "ISO8859-1");
	            }
	            Filedownload.save(content, "application/octet-stream", encodedName);
		}
		else {
            Messagebox.show("数据为空!");
            return;
        }
	        } 
	
	/**
	 * 清除变量
	 */
	public void clearVariable() {
		uecOutStaffInfomationVo = null;
		uecOutStaffInfoNew=null;
	}

	/**
	 * 查询按钮
	 * @throws ParseException 
	 */
	public void onQueryOutStaff() throws ParseException {
		if (!StrUtil.isEmpty(this.bean.getCode().getValue())) {
			uecOutStaffInfomationVo.setPsnCode(this.bean.getCode().getValue());
			uecOutStaffInfoNew.setPsnCode(this.bean.getCode().getValue());
		}
		if (!StrUtil.isEmpty(this.bean.getName().getValue())) {
			uecOutStaffInfomationVo.setPsnName(this.bean.getName().getValue());
			uecOutStaffInfoNew.setPsnName(this.bean.getName().getValue());
		}
		if (!StrUtil.isEmpty(this.bean.getIdNumber().getValue())) {
			uecOutStaffInfomationVo.setIdNum(this.bean.getIdNumber().getValue());
			uecOutStaffInfoNew.setIdNum(this.bean.getIdNumber().getValue());
		}
		onQueryUecOutStaffInfoVo();
	}
	/**
	 * 查询--uecOutStaffInfoVo
	 * @throws ParseException 
	 */
	@SuppressWarnings("unchecked")
	public void onQueryUecOutStaffInfoVo() throws ParseException {
			int activePage = bean.getUecOutStaffInfomationDownPaging().getActivePage();
			int pageSize = bean.getUecOutStaffInfomationDownPaging().getPageSize();
			PageInfo pageInfo = uecOutStaffInfomationManager.queryPageInfoByUecOutStaffInfomationVo(uecOutStaffInfomationVo, activePage + 1,
					pageSize);
			List<UecOutStaffInfomationVo> dataList2 = pageInfo.getDataList();
			//dataList2 = totalInfo(dataList2);
			ListModelList dataList = new BindingListModelList(dataList2, true);
			bean.getUecOutStaffInfomationDownbox().setModel(dataList);
			bean.getTotalSize().setValue(String.valueOf(pageInfo.getTotalCount()));
			bean.getUecOutStaffInfomationDownPaging().setTotalSize(pageInfo.getTotalCount());
	}

	/**
	 * 翻页
	 * @throws ParseException 
	 */
	public void onUecOutStaffListboxPaging() throws ParseException {
			this.onQueryUecOutStaffInfoVo();
	}
	
	
	  /**
		 * 学位
		 * @return
		 */
		public String getPkDegreeName(String pkdegree) {
			if (!StrUtil.isNullOrEmpty(pkdegree)) {
				String sql = "SELECT * FROM UEC_BD_DEFDOC WHERE PK_DEFDOC = ? ";
				List<Object> params = new ArrayList<Object>();
				params.add(pkdegree);
				List<UecBdDefdoc> list = DefaultDaoFactory.getDefaultDao().jdbcFindList(sql,
						params, UecBdDefdoc.class);
				if (list != null && list.size() > 0) {
					return list.get(0).getName();
				}
			
			}
			return null;
		}
		 public String dataTraslate(String data) throws ParseException {
		    	SimpleDateFormat df=new SimpleDateFormat("yyyy-mm");
		    	Date parse = df.parse(data);
		    	String newDate = df.format(parse);
		    	return newDate;
		    }
		 
		 
		 
		 //人员信息汇总下载
		 public List<UecOutStaffInfomationVo> totalInfo(List<UecOutStaffInfomationVo> qryUecOutStaffListByUecOutStaffInfo) throws ParseException {
				String pkdgreeName="";
				List<UecOutStaffInfomationVo> newlist=new ArrayList<UecOutStaffInfomationVo>();
				for (UecOutStaffInfomationVo uecOutStaffInfomationVo:qryUecOutStaffListByUecOutStaffInfo) {
					/*uecOutStaffInfo.setOutStaffId(uecOutStaffInfomationVo
							.getOutStaffId());
					uecOutStaffInfo = uecOutStaffManager
							.findUecOutStaffInfoById(uecOutStaffInfo);
					//考核		
				   List<UecAss> findUecAssByStaffId = uecAssManager
							.findUecAssByStaffId(uecOutStaffInfo);	
					//履历		
				   List<UecWork> queryPageInfoByUecStaffId = uecWorkManager
							.queryPageInfoByUecStaffId(uecOutStaffInfo);	
				  // 奖励
					List<UecEnc> findUecEncByOutStaffId = uecEncManager
							.findUecEncByOutStaffId(uecOutStaffInfo);	
				  // 教育
					List<UecDocEdu> uecDocEduByUecOutStaffId = uecEduManager
							.getUecDocEduByUecOutStaffId(uecOutStaffInfo);									
					*/
					 // 考核
					List<UecAss> findUecAssByStaffId = uecAssManager
							.findUecAssByOutAndStaffId(uecOutStaffInfomationVo);
					// 履历
				    List<UecWork> queryPageInfoByUecStaffId = uecWorkManager.queryPageInfoByUecOutAndStaffId(uecOutStaffInfomationVo);
					uecOutStaffInfomationVo.setListWork(queryPageInfoByUecStaffId);
					// 奖励
					List<UecEnc> findUecEncByOutStaffId = uecEncManager
							.findUecEncByOutAndStaffId(uecOutStaffInfomationVo);
					uecOutStaffInfomationVo.setListEnc(findUecEncByOutStaffId);
					// 教育
					List<UecDocEdu> uecDocEduByUecOutStaffId = uecEduManager
							.getUecDocEduByUecOutAndStaffId(uecOutStaffInfomationVo);
				//从事外包日期，
					String dataTemp="";
					if(queryPageInfoByUecStaffId != null && queryPageInfoByUecStaffId.size()>0) {
						UecWork uecWork = queryPageInfoByUecStaffId.get(0);
						if(!StrUtil.isNullOrEmpty(uecWork.getBegindate())){
						 dataTemp=uecWork.getBegindate();
						}
					}
					if(!StrUtil.isNullOrEmpty(dataTemp)) {
						  dataTemp=dataTraslate(dataTemp);
						}
					
						if(!StrUtil.isNullOrEmpty(dataTemp) && dataTemp.substring(4).length()<3) {
							dataTemp=dataTemp.substring(4)+"0"+dataTemp.substring(5);
						}
						if(!StrUtil.isNullOrEmpty(dataTemp)) {
							dataTemp=dataTemp.replace('-', '.');
							}	
						uecOutStaffInfomationVo.setWorkbegindate(dataTemp);		
				
				//教育经历
				if (uecDocEduByUecOutStaffId != null && uecDocEduByUecOutStaffId.size()>0) {
					for (UecDocEdu u : uecDocEduByUecOutStaffId) {
						if ("Y".equals(u.getLasteducation())) {
							uecOutStaffInfomationVo.setBestEnducation(u.getEducationName());
							uecOutStaffInfomationVo.setBestSchool(u.getSchool());
							uecOutStaffInfomationVo.setBestMajor(u.getMajor());
						}
						if ("Y".equals(u.getGlbdef4())) {
							if(!StrUtil.isNullOrEmpty(u.getPkDegree())) {
							   pkdgreeName = getPkDegreeName(u.getPkDegree());
							   uecOutStaffInfomationVo.setPkdegree(pkdgreeName);
						   }
							if(!"无".equals(pkdgreeName)) {
								uecOutStaffInfomationVo.setDegreeSchool(u.getSchool());
								uecOutStaffInfomationVo.setDegreeMajor(u.getMajor());
							}
							
						}
					}
					

				}
				if(findUecAssByStaffId.size()>0) {
					for (UecAss uecass : findUecAssByStaffId) {
						if (null != uecass.getGlbdef4()) {
							if (uecass.getGlbdef4().contains("15")) {
								uecOutStaffInfomationVo.setCheckResult15(uecass.getPkPerankName());
							} 
						  if (uecass.getGlbdef4().contains("16")) {
							  uecOutStaffInfomationVo.setCheckResult16(uecass.getPkPerankName());
						    } 
						  if (uecass.getGlbdef4().contains("17")) {
							  uecOutStaffInfomationVo.setCheckResult17(uecass.getPkPerankName());
						   } 
						}
					}	
			}
				newlist.add(uecOutStaffInfomationVo);
		}	
				
			return 	newlist;
		 }
	    //测试开始

			    public byte[] downData() throws ParseException, IOException {
			    	String path="C:/Users/BMP/Desktop/testnew.xlsx";
			        String name = "报名汇总表";
			        List<String> titles =new ArrayList<String>();
			        titles.add("组织");
			        titles.add("姓名");
			        titles.add("性别");
			        titles.add("出生日期");
			        titles.add("员工编号");
			        titles.add("身份证号码");
			        titles.add("现工作部门");
			        titles.add("现任职务或岗位");
			        titles.add("参加选聘报考类别");
			        titles.add("从事派遣或外包工作起始时间");
			        titles.add("原始学历");
			        titles.add("最高学历");
			        titles.add("最高学历毕业院校");
			        titles.add("最高学历所学专业");
			        titles.add("最高学位");
			        titles.add("最高学位毕业院校");
			        titles.add("最高学位所学专业");
			        titles.add("2015年度");
			        titles.add("2016年度");
			        titles.add("2017年度");
			        titles.add("岗级档次");
			        titles.add("政治面貌");
			        titles.add("健康状况");
			        titles.add("专业人才级别");
			        titles.add("专业人才聘期");
			        titles.add("工作简历\r\n" + 
			        		"(起止年月,工作单位,部门,任职或岗位)");
			        titles.add("获得荣誉\r\n" + 
			        		"（授予时间，授予荣誉，授予单位，奖励级别）");
			        titles.add("个人人事档案现存放单位");
			        titles.add("人员类别");
			       return writerExcel(path, name, titles,totalInfoList);
			    }

			    /**
			     * 数据写入Excel文件
			     *
			     * @param path 文件路径，包含文件全名，例如：D://file//demo.xls
			     * @param name sheet名称
			     * @param titles 行标题列
			     * @param values 数据集合，key为标题，value为数据
			     * @return True\False
			     * @throws ParseException 
			     * @throws IOException 
			     */
			    public byte[] writerExcel(String path, String name, List<String> titles, List<UecOutStaffInfomationVo> totalInfoList1) throws ParseException, IOException {
			    	String style = path.substring(path.lastIndexOf("."), path.length()).toUpperCase(); // 从文件路径中获取文件的类型
			        return generateWorkbook(path, name, style, titles, totalInfoList1);
			    }

			    /**
			     * 将数据写入指定path下的Excel文件中
			     *
			     * @param path   文件存储路径
			     * @param name   sheet名
			     * @param style  Excel类型
			     * @param titles 标题串
			     * @param values 内容集
			     * @return True\False
			     * @throws ParseException 
			     * @throws IOException 
			     */
			    private byte[] generateWorkbook(String path, String name, String style, List<String> titles, List<UecOutStaffInfomationVo> totalInfoList2) throws ParseException, IOException {
			        Workbook workbook;
			        if ("XLS".equals(style.toUpperCase())) {
			            workbook = new HSSFWorkbook();
			        } else {
			            workbook = new XSSFWorkbook();
			        }
			        // 生成一个表格
			        Sheet sheet;
			        if (null == name || "".equals(name)) {
			            sheet = workbook.createSheet(); // name 为空则使用默认值
			        } else {
			            sheet = workbook.createSheet(name);
			        }
			        // 设置表格默认列宽度为15个字节
			        sheet.setDefaultColumnWidth((short) 15);
			        // 生成样式
			        Map<String, CellStyle> styles = createStyles(workbook);
			        /*
			         * 创建标题行
			         */
			        Row row = sheet.createRow(0);
			        // 存储标题在Excel文件中的序号
			       // Map<String, Integer> titleOrder = new HashMap<String, Integer>();
			        for (int i = 0; i < titles.size(); i++) {
			            Cell cell = row.createCell(i);
			            //celllist.add(cell);
			            cell.setCellStyle(styles.get("header"));
			            String title = titles.get(i);
			            cell.setCellValue(title);
			          //  titleOrder.put(title, i);
			        }
			        /*
			            * 写入正文
			         */
			        String value="";
			        //遍历行，从第二行开始
			        int cellNum=titles.size();
			        for(int i=1;i<=totalInfoList2.size();i++) {
			            row = sheet.createRow(i);
			            i=i-1;
			             //单元格
			                 for (int j=0;j<cellNum;j++) {
			                	 Cell cell0=null;
					             Cell cell1=null;
					             Cell cell2=null;
					             Cell cell3=null;
					             Cell cell4=null;
					             Cell cell5=null;
					             Cell cell6=null;
					             Cell cell7=null;
					             Cell cell8=null;
					             Cell cell9=null;
					             Cell cell10=null;
					             Cell cell11=null;
					             Cell cell12=null;
					             Cell cell13=null;
					             Cell cell14=null;
					             Cell cell15=null;
					             Cell cell16=null;
					             Cell cell17=null;
					             Cell cell18=null;
					             Cell cell19=null;
					             Cell cell20=null;
					             Cell cell21=null;
					             Cell cell22=null;
					             Cell cell23=null;
					             Cell cell24=null;
					             Cell cell25=null;
					             Cell cell26=null;
					             Cell cell27=null;
					             Cell cell28=null;
			                	 switch (j) {
			                		 case 0:
			                		  cell0=row.createCell(j);
					                  cell0.setCellValue(totalInfoList2.get(i).getOrgName());
					                  break;
			                		 case 1:
			                			 cell1=row.createCell(j);
						                  cell1.setCellValue(totalInfoList2.get(i).getPsnName());
						                  break; 
			                		 case 2:
			                			 cell2=row.createCell(j);
						                  cell2.setCellValue(totalInfoList2.get(i).getSex()); 
						                  break;  
			                		 case 3:
			                			cell3=row.createCell(j);
			                			 cell3.setCellValue(totalInfoList2.get(i).getBirthdate()); 
			                			 break;
			                		 case 4:
			                			 cell4=row.createCell(j);
			                			 cell4.setCellValue(totalInfoList2.get(i).getPsnCode()); 
			                			 break;
			                		 case 5:
			                			 cell5=row.createCell(j);
			                			 cell5.setCellValue(totalInfoList2.get(i).getIdNum());  
			                			 break;
			                		 case 6:
			                			 cell6=row.createCell(j);
			                			 cell6.setCellValue(totalInfoList2.get(i).getDeptName());
			                			 break;     
			                		 case 7:
			                			 cell7=row.createCell(j);
			                			 cell7.setCellValue(totalInfoList2.get(i).getJobglbdef4()); 
			                			 break;    
			                		 case 8:
			                			 cell8=row.createCell(j);
			                			 cell8.setCellValue(value);  
			                			 break;   
			                		 case 9:
			                			 cell9=row.createCell(j);
			                			 cell9.setCellValue(totalInfoList2.get(i).getWorkbegindate()); 
			                			 break;    
			                		 case 10:
			                			 cell10=row.createCell(j);
			                			 cell10.setCellValue(value); 
			                			 break;    
			                		 case 11:
			                			 cell11=row.createCell(j);
			                			 cell11.setCellValue(totalInfoList2.get(i).getBestEnducation());  
			                			 break;   
			                		 case 12:
			                			 cell12=row.createCell(j);
			                			 cell12.setCellValue(totalInfoList2.get(i).getBestSchool());  
			                			 break;   
			                		 case 13:
			                			 cell13=row.createCell(j);
			                			 cell13.setCellValue(totalInfoList2.get(i).getBestMajor());   
			                			 break;  
			                		 case 14:
			                			 cell14=row.createCell(j);
			                			 cell14.setCellValue(totalInfoList2.get(i).getPkdegree()); 
			                			 break;    
			                		 case 15:
			                			 cell15=row.createCell(j);
			                			 cell15.setCellValue(totalInfoList2.get(i).getDegreeSchool()); 
			                			 break;    
			                		 case 16:
			                			 cell16=row.createCell(j);
			                			 cell16.setCellValue(totalInfoList2.get(i).getDegreeMajor());  
			                			 break;   
			                		 case 17:
			                			 cell17=row.createCell(j);
			                			 cell17.setCellValue(totalInfoList2.get(i).getCheckResult15()); 
			                			 break;    
			                		 case 18:
			                			 cell18=row.createCell(j);
			                			 cell18.setCellValue(totalInfoList2.get(i).getCheckResult16());   
			                			 break;  
			                		 case 19:
			                			 cell19=row.createCell(j);
			                			 cell19.setCellValue(totalInfoList2.get(i).getCheckResult17()); 
			                			 break;    
			                		 case 20:
			                			 cell20=row.createCell(j);
			                			 cell20.setCellValue(totalInfoList2.get(i).getJobglbdef3()); 
			                			 break;    
			                		 case 21:
			                			 cell21=row.createCell(j);
			                			 cell21.setCellValue(totalInfoList2.get(i).getPartyName());  
			                			 break;   
			                		 case 22:
			                			 cell22=row.createCell(j);
			                			 cell22.setCellValue(totalInfoList2.get(i).getHealth());  
			                			 break;   
			                		 case 23:
			                			 cell23=row.createCell(j);
			                			 cell23.setCellValue(totalInfoList2.get(i).getTalentRank());  
			                			 break;   
			                		 case 24:
			                			 cell24=row.createCell(j);
			                			 cell24.setCellValue(totalInfoList2.get(i).getTalentDate());  
			                			 break;  
			                		 case 25:
			                			 cell25=row.createCell(j);
			                			 cell25.setCellValue(totalInfoList2.get(i).getWorkCollectionName()); 
			                			 break;    
			                		 case 26:
			                			 cell26=row.createCell(j);
			                			 cell26.setCellValue(totalInfoList2.get(i).getEncCollectionName());
			                			 break;     
			                		 case 27:
			                			 cell27=row.createCell(j);
			                			 cell27.setCellValue(totalInfoList2.get(i).getFileaddress()); 
			                			 break;    
			                		 case 28:
			                			 cell28=row.createCell(j);
			                			 cell28.setCellValue(totalInfoList2.get(i).getPslName()); 
			                			 break;    
			                	    default:
			                	    	break;
			                	 }
			                 }
			                
			            }
			       // }
			        /*
			         * 写入到文件中
			         */
			        ByteArrayOutputStream os = new ByteArrayOutputStream();
			        /*try {
			            File file = new File(path);
			            if(file.exists()) {
			            	file.deleteOnExit();
			            	file.createNewFile();
			            }else {
			            	file.createNewFile();
			            }*/
			        /*} catch (IOException e) {
		            isCorrect = false;
		            e.printStackTrace();
		        }*/
			            workbook.write(os);
			        try {
			            workbook.close();
			        } catch (IOException e) {
			            e.printStackTrace();
			        }
			        if (os != null) {
						byte[] bs = os.toByteArray();
						os.close();
						return bs;
					}
			        
			        return null;
			    }

			    /**
			     * Create a library of cell styles
			     */
			    /**
			     * @param wb
			     * @return
			     */
			    private static Map<String, CellStyle> createStyles(Workbook wb) {
			        Map<String, CellStyle> styles = new HashMap<String, CellStyle>();

			        // 标题样式
			        CellStyle titleStyle = wb.createCellStyle();
			        titleStyle.setAlignment(HorizontalAlignment.CENTER); // 水平对齐
			        titleStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 垂直对齐
			        titleStyle.setLocked(true); // 样式锁定
			        titleStyle.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.getIndex());
			        Font titleFont = wb.createFont();
			        titleFont.setFontHeightInPoints((short) 16);
			        titleFont.setBold(true);
			        titleFont.setFontName("微软雅黑");
			        titleStyle.setFont(titleFont);
			        styles.put("title", titleStyle);

			        // 文件头样式
			        CellStyle headerStyle = wb.createCellStyle();
			        headerStyle.setAlignment(HorizontalAlignment.CENTER);
			        headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
			        headerStyle.setFillForegroundColor(IndexedColors.LIGHT_BLUE.getIndex()); // 前景色
			        headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); // 颜色填充方式
			        headerStyle.setWrapText(true);
			        headerStyle.setBorderRight(BorderStyle.THIN); // 设置边界
			        headerStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
			        headerStyle.setBorderLeft(BorderStyle.THIN);
			        headerStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
			        headerStyle.setBorderTop(BorderStyle.THIN);
			        headerStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
			        headerStyle.setBorderBottom(BorderStyle.THIN);
			        headerStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
			        Font headerFont = wb.createFont();
			        headerFont.setFontHeightInPoints((short) 12);
			        headerFont.setColor(IndexedColors.WHITE.getIndex());
			        titleFont.setFontName("微软雅黑");
			        headerStyle.setFont(headerFont);
			        styles.put("header", headerStyle);

			        Font cellStyleFont = wb.createFont();
			        cellStyleFont.setFontHeightInPoints((short) 12);
			        cellStyleFont.setColor(IndexedColors.BLUE_GREY.getIndex());
			        cellStyleFont.setFontName("微软雅黑");
			        
			        // 正文样式A
			        CellStyle cellStyleA = wb.createCellStyle();
			        cellStyleA.setAlignment(HorizontalAlignment.CENTER); // 居中设置
			        cellStyleA.setVerticalAlignment(VerticalAlignment.CENTER);
			        cellStyleA.setWrapText(true);
			        cellStyleA.setBorderRight(BorderStyle.THIN);
			        cellStyleA.setRightBorderColor(IndexedColors.BLACK.getIndex());
			        cellStyleA.setBorderLeft(BorderStyle.THIN);
			        cellStyleA.setLeftBorderColor(IndexedColors.BLACK.getIndex());
			        cellStyleA.setBorderTop(BorderStyle.THIN);
			        cellStyleA.setTopBorderColor(IndexedColors.BLACK.getIndex());
			        cellStyleA.setBorderBottom(BorderStyle.THIN);
			        cellStyleA.setBottomBorderColor(IndexedColors.BLACK.getIndex());
			        cellStyleA.setFont(cellStyleFont);
			        styles.put("cellA", cellStyleA);

			        // 正文样式B:添加前景色为浅黄色
			        CellStyle cellStyleB = wb.createCellStyle();
			        cellStyleB.setAlignment(HorizontalAlignment.CENTER);
			        cellStyleB.setVerticalAlignment(VerticalAlignment.CENTER);
			        cellStyleB.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.getIndex());
			        cellStyleB.setFillPattern(FillPatternType.SOLID_FOREGROUND);
			        cellStyleB.setWrapText(true);
			        cellStyleB.setBorderRight(BorderStyle.THIN);
			        cellStyleB.setRightBorderColor(IndexedColors.BLACK.getIndex());
			        cellStyleB.setBorderLeft(BorderStyle.THIN);
			        cellStyleB.setLeftBorderColor(IndexedColors.BLACK.getIndex());
			        cellStyleB.setBorderTop(BorderStyle.THIN);
			        cellStyleB.setTopBorderColor(IndexedColors.BLACK.getIndex());
			        cellStyleB.setBorderBottom(BorderStyle.THIN);
			        cellStyleB.setBottomBorderColor(IndexedColors.BLACK.getIndex());
			        cellStyleB.setFont(cellStyleFont);
			        styles.put("cellB", cellStyleB);

			        return styles;
			    } 
			  //测试结束 
		 
}
